﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Text;
using System.Windows.Forms;

namespace NetTao.Spider.Win
{
    public partial class FrmMain : Form
    {
        public FrmMain()
        {
            InitializeComponent();
        }

        private void 类别管理ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //const string flag = "类别管理";
            //if (!tabControl1.TabPages.ContainsKey(flag))
            //{
            //    var tabPage = new TabPage(flag) {Name = flag};
            //    var uc = new Manage.UcClassManage {Dock = DockStyle.Fill};
            //    tabPage.Controls.Add(uc);
            //    tabControl1.TabPages.Add(tabPage);
            //}
            //SelectTabPage(flag);
        }

        void SelectTabPage(string text)
        {
            foreach (TabPage tab in tabControl1.TabPages)
            {
                if (tab.Text.Equals(text))
                {
                    tabControl1.SelectedTab = tab;
                }
            }
        }

        private void ToolStripButton1Click(object sender, EventArgs e)
        {
            var spider=new NovelSpider();
            spider.Work();
        }

        private void BtnTestClick(object sender, EventArgs e)
        {
            if (txtLink.Text.Length > 0)
            {
                richTextBox1.Clear();
                string content = Utils.HttpHelper.Get(txtLink.Text, Encoding.GetEncoding(cmbEncoding.Text));
                if (!string.IsNullOrEmpty(content))
                    richTextBox1.AppendText(content);
            }
        }

        private void ToolStripButton5Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
